package com.twschool.practice.guessnumber;

import java.util.Random;

public class GenerateRandomNumber {
    public String random(){
        Random random = new Random();
        int[] arr = new int[4];
        arr[0] = random.nextInt(9);
        int i = 1;
        while(i <=3) {
            int x = random.nextInt(9);

            for (int j = 0; j <= i - 1; j++) {
                if (arr[j] == x) {
                    break;
                }
                if(j+1==i){
                    arr[i] = x;
                    i++;
                }
            }
        }
        String result = "";
        for (int num : arr) {
            result+=num;
        }
        return result;
    }
}
